use std::fs;

use lrlex::lrlex_mod;
use lrpar::lrpar_mod;
use markdown_parser::parse;

// Using `lrlex_mod!` brings the lexer for `calc.l` into scope. By default the
// module name will be `calc_l` (i.e. the file name, minus any extensions,
// with a suffix of `_l`).
lrlex_mod!("markdown.l");
// Using `lrpar_mod!` brings the parser for `calc.y` into scope. By default the
// module name will be `calc_y` (i.e. the file name, minus any extensions,
// with a suffix of `_y`).
lrpar_mod!("markdown.y");
fn main() {
    let l = fs::read_to_string("markdown_parser/README.md").unwrap();
    let (res, errs) = parse(&l);
    match res {
        Some(r) => {
            for ele in r.iter() {
                println!("{}", &ele);
            }
        }
        e => eprintln!("Unable to evaluate expression.{:?}", e),
    }
    if let Some(errs) = errs {
        println!("{}", errs);
    }
}
